package com.woniuxy.propertyjava.service.impl;

import com.woniuxy.propertyjava.dao.CleaningDao;
import com.woniuxy.propertyjava.entity.Cleaning;
import com.woniuxy.propertyjava.entity.PageBean;
import com.woniuxy.propertyjava.service.CleaningService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : author
 * @create 2022/7/5 16:05
 */
@Service
public class CleaningServiceImpl implements CleaningService {

    @Resource(type = CleaningDao.class)
    CleaningDao cleaningDao;

    @Override
    public PageBean<Cleaning> getCleaningPageBean(Cleaning cleaning, int pageIndex, int pageSize) {
        PageBean<Cleaning> pageBean = new PageBean<>();
        pageBean.setBeanList(cleaningDao.selectCleaningsByCleaningProperty(cleaning, pageIndex, pageSize));
        pageBean.setPageSize(pageSize);
        pageBean.setPageIndex(pageIndex);
        pageBean.setTotalRecode(cleaningDao.count(cleaning));
        return pageBean;
    }

    @Override
    public void insertCleaning(Cleaning cleaning) {
        cleaningDao.insert(cleaning);
    }

    @Override
    public void updataCleaning(Cleaning cleaning) {
        cleaningDao.update(cleaning);
    }

    @Override
    public void deleteCleaning(int cleaningId) {
        cleaningDao.deleteById(cleaningId);
    }
}
